package cn.geminis.workflow.service.service.engine.listener;

import cn.geminis.workflow.service.service.model.RemoteDataService;
import cn.geminis.workflow.service.utils.SpringUtils;
import org.flowable.common.engine.api.delegate.Expression;
import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.delegate.ExecutionListener;

/**
 * @author puddi
 */
public class RunRemoteExecutionListener implements ExecutionListener {

    private Expression value;
    private Expression url;

    @Override
    public void notify(DelegateExecution delegateExecution) {
        var client = SpringUtils.getBean(RemoteDataService.class);
        var calcUrl = url.getValue(delegateExecution).toString();
        var calcValue = value.getValue(delegateExecution).toString();
        client.run(calcUrl, calcValue);
    }

}
